home *** CD-ROM | disk | FTP | other *** search
/ The Sunday Times: The Month 2004 August / The Sunday Times - The Month 2004-08.iso / pc / engine / modules / calculator_audio.swf / scripts / frame_1 / DoAction.as
Encoding:
Text File  |  2004-06-24  |  3.8 KB  |  122 lines

  1. function init()
  2. {
  3.    var _loc2_ = Tardis.ActiveSection.id;
  4.    var _loc1_ = Tardis.Colors;
  5.    strSECTION_COLOR = _loc1_.getString(_loc2_);
  6.    SECTION_COLOR = _loc1_.getHex(_loc2_);
  7.    strSECTION_COLOR50 = _loc1_.getString(_loc2_ + "50");
  8.    SECTION_COLOR50 = _loc1_.getHex(_loc2_ + "50");
  9.    DEFAULT_COLOR = _loc1_.getHex("default");
  10.    DEFAULT_COLOR50 = _loc1_.getString("default50");
  11.    strDEFAULT_COLOR = _loc1_.getString("default");
  12.    ndTracks = nodeData.byName("track");
  13.    strTrackpath = Tardis.ASSETS_FOLDER + ndTracks.attributes.path;
  14.    audioText_FF.htmlText = ndTracks.byName("body").getText();
  15.    audioText_FF.textColor = DEFAULT_COLOR;
  16.    var strTitle = "<FONT COLOR=\"" + strSECTION_COLOR + "\">" + nodeData.byName("labels").byName("title").getText() + "</FONT> ";
  17.    title_FF.htmlText = strTitle;
  18.    var strIntro = "<FONT COLOR=\"" + strDEFAULT_COLOR + "\">" + nodeData.byName("labels").byName("intro").getText() + "</FONT> ";
  19.    intro_FF.htmlText = strIntro;
  20.    currency_1.htmlText = currency_2.htmlText = nodeData.byName("labels").byName("currency").getText();
  21.    var _loc3_ = "<FONT COLOR=\"" + strDEFAULT_COLOR + "\">" + nodeData.byName("labels").byName("byline1").getText() + "</FONT> ";
  22.    byline_1.htmlText = _loc3_;
  23.    var strByline2 = "<FONT COLOR=\"" + strDEFAULT_COLOR + "\">" + nodeData.byName("labels").byName("byline2").getText() + "</FONT> ";
  24.    byline_2.htmlText = strByline2;
  25.    calculate.txt.htmlText = nodeData.byName("labels").byName("calculate").getText();
  26.    calculate.txt.autoSize = "left";
  27.    calculate.arrowMC._x = calculate.txt._width + 4;
  28.    cost = nodeData.byName("cost").getText();
  29.    _visible = true;
  30.    playSound();
  31.    onComplete();
  32. }
  33. function interrupt()
  34. {
  35.    fade(this.snd,0);
  36. }
  37. function resume()
  38. {
  39.    trackUp(mc_t_1);
  40. }
  41. function playSound()
  42. {
  43.    createEmptyMovieClip("mc_sound",Tardis.depth++);
  44.    snd = new Sound(mc_sound);
  45.    var _loc1_ = strPathPrefix + strTrackpath + ndTracks.byName("file").firstChild.nodeValue;
  46.    snd.loadSound(_loc1_,false);
  47.    snd.onLoad = function()
  48.    {
  49.       this.start();
  50.       mc_timebar.play();
  51.       mc_controls.gotoAndStop("active");
  52.    };
  53. }
  54. function resumeSound(posToStart)
  55. {
  56.    var _loc1_ = posToStart;
  57.    if(_loc1_ == null)
  58.    {
  59.       sndPos = snd.position / 1000;
  60.    }
  61.    else
  62.    {
  63.       sndPos = _loc1_;
  64.    }
  65.    if(_loc1_ == 0)
  66.    {
  67.       trackUp(currentTrack);
  68.    }
  69.    else
  70.    {
  71.       snd.start(sndPos,1);
  72.    }
  73. }
  74. function pauseSound()
  75. {
  76.    snd.stop();
  77. }
  78. function stopSound()
  79. {
  80.    snd.stop();
  81.    delete snd;
  82.    mc_sound.removeMovieClip();
  83. }
  84. _visible = false;
  85. onReady();
  86. onReady();
  87. this.onUnload = function()
  88. {
  89.    interrupt();
  90.    removeLinkListener();
  91.    this.onUnload = null;
  92. };
  93. var cost;
  94. calculate.onPress = function()
  95. {
  96.    var _loc1_ = Math.ceil(cost / Number(income_txt.text));
  97.    if(_loc1_ == Infinity || isNaN(_loc1_) || _loc1_ < 1)
  98.    {
  99.       var _loc3_ = "<FONT COLOR=\"" + strSECTION_COLOR + "\">" + nodeData.byName("labels").byName("result1").getText() + "</FONT> ";
  100.       output1.htmlText = _loc3_;
  101.    }
  102.    else if(_loc1_ > 104)
  103.    {
  104.       _loc3_ = "<FONT COLOR=\"" + strSECTION_COLOR + "\">" + nodeData.byName("labels").byName("result2").getText() + "</FONT> ";
  105.       output1.htmlText = _loc3_;
  106.    }
  107.    else if(_loc1_ > 1)
  108.    {
  109.       var _loc2_ = nodeData.byName("labels").byName("result4").getText().split("|");
  110.       _loc3_ = "<FONT COLOR=\"" + strSECTION_COLOR + "\">" + _loc2_[0] + " " + _loc1_ + " " + _loc2_[1] + "</FONT> ";
  111.       output1.htmlText = _loc3_;
  112.    }
  113.    else
  114.    {
  115.       _loc2_ = nodeData.byName("labels").byName("result3").getText().split("|");
  116.       _loc3_ = "<FONT COLOR=\"" + strSECTION_COLOR + "\">" + _loc2_[0] + " " + _loc1_ + " " + _loc2_[1] + "</FONT> ";
  117.       output1.htmlText = _loc3_;
  118.    }
  119. };
  120. Selection.setFocus(income_txt);
  121. Selection.setSelection(10,10);
  122.